<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Contract-add</title>
    <!-- 引入layui 样式-->
    <link rel="stylesheet" href="../../static/css/style.css"/>
    <link rel="stylesheet" href="../../static/layer/css/layui.css"/>
    <link rel="stylesheet" href="../../static/css/font-awesome.min.css">
    <link rel="stylesheet" href="../../static/ucss/contract/loan.css"/>
    <style>
        .layui-form{
            margin-left: 7%;
            margin-top: 20px;
        }
        .layui-form-label{
            width:200px!important;
        }

    </style>
</head>

<body>
<form class="layui-form" action=""  id="realestateinfo_id">

    <input type="hidden" name="ID" ID="ID" >

   <!-- <div class="layui-form-item  ">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-inline">
            <select name="TYPE" >
                <option value="1">房屋</option>
                <option value="2">土地</option>
            </select>
        </div>
    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-block">
            <input type="radio" name="TYPE" value="1" title="房屋" checked  >
            <input type="radio" name="TYPE" value="2" title="土地" >
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label class_sh_name">面积(㎡)</label>
        <div class="layui-input-inline">
            <input type="text" name="MEASURE_AREA"   id="MEASURE_AREA"  lay-verify="number"  maxlength="10"  placeholder="请输入面积" autocomplete="off" class="layui-input">
        </div>

    </div>




    <div class="layui-form-item class_company_type_one">
        <label class="layui-form-label">坐落位置</label>
        <div class="layui-input-inline">
            <input type="text" name="LOCATION"   placeholder="请输入坐落位置"   lay-verify="required"  maxlength="30"  autocomplete="off" class="layui-input">
        </div>

    </div>

    <div class="layui-form-item  ">
        <label class="layui-form-label">产权人</label>
        <div class="layui-input-inline">
            <select name="PROPERTY_HOLDER" >
                <option value="1">本企业</option>
                <option value="2">股东/法人</option>
                <option value="3">企业高管人员</option>
                <option value="4">第三方</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item  class_isShow_type">
        <label class="layui-form-label">抵押估值(元)</label>
        <div class="layui-input-inline">
            <input type="text" name="MORTGAGE_VAL" id="MORTGAGE_VAL"  lay-verify="number"  maxlength="20"  placeholder="请输入抵押估值" autocomplete="off" class="layui-input">
        </div>

    </div>




    <div class="layui-form-item"  style="padding-top: 20px;">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo"   style="margin-left: 85px;" type="button">提交</button>
            <button type="button" class="layui-btn layui-btn-primary" onclick="cancel()">返回</button>
        </div>
    </div>
</form>

</body>
<script type="text/javascript" src="../../static/layer/layui.js"></script>
<script type="text/javascript" src="../../static/js/common/dateUtils.js"></script>
<script type="text/javascript" src="../../static/js/common/typeUtils.js"></script>
<script type="text/javascript" src="../../static/js/common/queryUtils.js"></script>
<script type="text/javascript" src="../../static/js/common/utils.js"></script>
<script>
    //Demo
    var $, element, layer, laydate, form,table;
    var UUID = QueryUtils.GetQueryString("UUID");//合同id

    var ID = QueryUtils.GetQueryString("ID");//股东ID
    layui.use(['jquery', 'element', 'layer', 'laydate', 'form', 'upload','table'], function () {
        // 加载元素控件
        $ = layui.jquery, element = layui.element, layer = layui.layer, laydate = layui.laydate,table = layui.table, form = layui.form;

        //是否回显
        isShow(ID);


//自定义验证规则
        form.verify({

            number: function (value) {
                debugger

                var reg = /^\d+(\.\d+)?$/;
                if (value=="") {
                    return '必填项不能为空';
                }
                if (!reg.test(value)) {
                    return '你输入的字符不是数字';
                }


            },
            num: function (value) {
                var reg = /^[0-9]*$/;

                if (value=="") {
                    return '必填项不能为空';
                }
                if (!reg.test(value)) {
                    return '你输入的字符不是数字';
                }

            }


        })

        //监听提交
        form.on('submit(formDemo)', function(data){


            var dataList = {};

            dataList=data.field;


            dataList.LOAN_ID=UUID;
            layer.msg('确认新增抵押物不动产信息吗', {
                time: 0
                , btn: ['确定', '取消']
                , shade: 0.3
                , yes: function (index) {
                    layer.close(index); // 关闭当前提示框
                    var i = parent.layer.getFrameIndex(window.name);



                    $.ajax({
                        url: "/LoanQTController/saveCllateralInfo",
                        data: dataList,
                        dataType: "json",
                        type: "post",
                        async: false,
                        success: function (res) {
                            if (res.errcode === "0") {
                                debugger
                             //   window.parent.frames[0].test();
                                parent.layer.close(i);  // 关闭新建合同页面
                                parent.layer.msg("保存成功");   // 父页面弹出保存成功
                            } else if (res.errcode === "1") {
                                layer.msg("保存失败");
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.msg("保存失败");
                            console.error(XMLHttpRequest.status);
                            console.error(XMLHttpRequest.readyState);
                            console.error(textStatus);
                        }
                    });
                }
            });
        });

        form.on('radio(radio_type)', function(data){
            radioType(data.value);
        });
    });



//是否回显
    function  isShow(ID){
        debugger
        if(ID!=null && ID!="" && typeof(ID)!="undefined" ){
            var sendData={};
            sendData.ID=ID;
            $.ajax({
                url: "/LoanQTController/findByIdCollateralInfo",
                data: sendData,
                dataType: "json",
                type: "post",
                async: false,
                success: function (res) {

                    if (res.errcode === "0") {
                        utils.setFormData("#realestateinfo_id",res.data);
                        form.render();
                    } else if (res.errcode === "1") {
                        layer.msg("查询失败");

                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.msg("查询失败");
                    console.error(XMLHttpRequest.status);
                    console.error(XMLHttpRequest.readyState);
                    console.error(textStatus);
                }
            });

        }

    }
    // 取消
   function cancel() {
        // 当你在iframe页面关闭自身时
        var index = parent.layer.getFrameIndex(window.name); // 先得到当前iframe层的索引
        parent.layer.close(index); // 再执行关闭
    }


</script>
</html>